package com.jspx.txweb.table;

import com.jspx.boot.environment.Environment;
import com.jspx.sober.annotation.Column;
import com.jspx.sober.annotation.IDType;
import com.jspx.sober.annotation.Id;
import com.jspx.sober.annotation.Table;

/**
 * Created by Administrator on 2017/6/11.
 * 让tomcat 的session数据保存在数据库中
 * <p>
 * CREATE TABLE `tomcat_session` (
 * `sessionId` varchar(128) DEFAULT NULL,
 * `sessionData` mediumblob,
 * `maxInactive` int(128) DEFAULT NULL,
 * `lastAccessed` bigint(20) DEFAULT NULL,
 * `sessionApp` varchar(128) DEFAULT NULL,
 * `sessionValid` char(2) DEFAULT NULL
 * ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 * <p>
 * <p>
 * <p>
 * <Manager className="org.apache.catalina.session.PersistentManager"
 * saveOnRestart="true"
 * maxActiveSession="-1"
 * minIdleSwap="0"
 * maxIdleSwap="30"
 * maxIdleBackup="0"
 * >
 * <!-- db store -->
 * <Store className="org.apache.catalina.session.JDBCStore"
 * driverName="com.mysql.jdbc.Driver"
 * connectionURL="jdbc:mysql://localhost:3306/demo?user=root&amp;password=123456"
 * sessionTable="tomcat_session"
 * sessionIdCol="sessionId"
 * sessionDataCol="sessionData"
 * sessionValidCol="sessionValid"
 * sessionMaxInactiveCol="maxInactive"
 * sessionLastAccessedCol="lastAccessed"
 * sessionAppCol="sessionApp"
 * checkInterval="60"
 * debug="99" />
 * </Manager>
 */
@Table(name = "tomcat_session", caption = "在线信息", cache = true)
public class TomcatSession {

    @Column(caption = "sessionId", dataType = "isLengthBetween(1,250)", length = 130)
    private String sessionId;

    @Column(caption = "data", length = 50000, defaultValue = "", notNull = false)
    private String sessionData;

    @Column(caption = "最大有效期", defaultValue = "0", notNull = true)
    private long maxInactive;

    @Column(caption = "最后访问时间", defaultValue = "0", notNull = true)
    private long lastAccessed;

    @Column(caption = "sessionApp", length = 130, notNull = false)
    private String sessionApp;

    @Column(caption = "sessionApp", length = 2, notNull = false)
    private String sessionValid;

    public String getSessionId() {
        return sessionId;
    }

    public void setSessionId(String sessionId) {
        this.sessionId = sessionId;
    }

    public String getSessionData() {
        return sessionData;
    }

    public void setSessionData(String sessionData) {
        this.sessionData = sessionData;
    }

    public long getMaxInactive() {
        return maxInactive;
    }

    public void setMaxInactive(long maxInactive) {
        this.maxInactive = maxInactive;
    }

    public long getLastAccessed() {
        return lastAccessed;
    }

    public void setLastAccessed(long lastAccessed) {
        this.lastAccessed = lastAccessed;
    }

    public String getSessionApp() {
        return sessionApp;
    }

    public void setSessionApp(String sessionApp) {
        this.sessionApp = sessionApp;
    }

    public String getSessionValid() {
        return sessionValid;
    }

    public void setSessionValid(String sessionValid) {
        this.sessionValid = sessionValid;
    }
}
